﻿using KillBill.Presentation.Modules.Administration.IView;
using KillBill.Presentation.Modules.Administration.SecurityServiceReference;

namespace KillBill.Presentation.Modules.Administration.Presenter
{
    public class LogInPresenter
    {
        SecurityServiceClient _service = new SecurityServiceClient();

        public LogInPresenter(ILogIn view)
        {
            View = view;
        }
        public ILogIn View { get; set; }
        public void Autenticate()
        {
            Session session = _service.LogIn(View.Id, View.Password);
            if (session.Success)
            {
                Context.ActiveSession = session;
            }
            else
            {
                if (session.Messages != null && session.Messages.Count > 0)
                    View.ShowMessage(session.Messages[0]);
            }
        }
    }
}
